package com.chzu.controller;

import com.chzu.pojo.SysUser;
import com.chzu.result.JsonResult;
import com.chzu.result.QueryInfo;
import com.chzu.service.SysUserService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;

/**
 * @Author lz
 * @Version 1.0
 * @Company 滁州大健康与养老产业研究院
 * @ClassName SysUserController
 * @Description TODO
 * @Date 2022/02/05 22:43
 */
@RestController
@Api(tags = "用户数据的接口")
@RequestMapping("/user")
public class SysUserController {
    @Resource
    private SysUserService userService;

    @ApiOperation(value = "分页查询")
    @PostMapping("/findPage")
    public JsonResult<Object> findPage(@RequestBody QueryInfo queryInfo) {
        return userService.findPage(queryInfo);
    }

    @ApiOperation(value = "添加用户")
    @PostMapping("/insert")
    public JsonResult<Object> insertUser(@RequestBody  SysUser user) {
        return userService.insertUser(user);
    }

    @ApiOperation(value = "修改用户信息")
    @PutMapping("/update")
    public JsonResult<Object> updateUser(@RequestBody SysUser user) {
        return userService.updateUser(user);
    }

    @ApiOperation(value = "删除用户信息")
    @DeleteMapping("/delete/{id}")
    public JsonResult<Object> deleteUser(@PathVariable("id") Integer id) {
        return userService.deleteUser(id);
    }
}
